package com.fary.uri;

import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;

import java.util.Arrays;

/**
 * @author Fary
 * @version 1.0
 * @description: TODO
 * @date 2022/3/15 15:26
 */
public class TestUriComponents {

    public static void main(String[] args) {
        MultiValueMap<String, String> params = new LinkedMultiValueMap<String, String>();
        params.put("hotel", Arrays.asList("1"));
        params.put("booking", Arrays.asList("2"));
        UriComponents uriComponents = UriComponentsBuilder
                .fromHttpUrl("http://localhost:8080/hotels/{hotel}/bookings/{booking}")
                .queryParams(params).build(); //params是个Map
        String uri = uriComponents.toUriString();
    }
}
